<?php

namespace app\common\model;

use app\admin\model\Admin;
use think\Db;
use think\Model;
use traits\model\SoftDelete;

class OrderAddress extends Model
{

    use SoftDelete;

    

    // 表名
//    protected $name = 'order_address';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'create_time';
//    protected $updateTime = 'updatetime';
//    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
    ];

    /**
     * 新增
     * */
    public static function OrderAddressAdd($address_id,$type){
        $addressInfo = Address::where(['id'=>$address_id])->find()->toArray();
//        dd($addressInfo);
//        $addressInfo['create_time'] = time();
        $addressInfo['type'] = $type;
        unset($addressInfo['id']);
        unset($addressInfo['label']);
        unset($addressInfo['is_default']);
        unset($addressInfo['delete_time']);

        $info = self::create($addressInfo);
//        dd($info);
        return $info['id'];
    }

}
